<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我来帮你选</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <style>
        body{
    background-color:#ddd;
}   
.bg1 {
    position: absolute;
    bottom: 0px;
    height: 300px;
    width: 100%;
    background: url(image/bg1.png) repeat-x;
    animation: change_bg 5s linear infinite;
}

.bg2 {
    position: absolute;
    bottom: 0px;
    height: 300px;
    width: 100%;
    z-index: 1;
    background: url(image/bg2.png) repeat-x;
    animation: change_bg 5s linear infinite;
}

.img {
    position: fixed;
    bottom: 10px;
    height: 100px;
    width: 200px;
    z-index: 2;
    background: url(image/bear.png);
    animation: bear .4s steps(8) infinite, change_pos 2s forwards;
}

@keyframes bear {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: -1600px 0;
    }
}

@keyframes change_pos {
    0% {
        left: 0;
    }
    100% {
        left: 50%;
        transform: translate(-50%, 0);
    }
}

@keyframes change_bg {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: -3840px 0;
    }
}
    </style>
    <script>
        var dinyi = prompt("选择你正在犯难的选择" + '\n' + '1.吃还是不吃' + '\n' + '2.去还是不去' + '\n' + '3.运动还是不运动' + '\n' + '4.买还是不买' + '\n' + '5.听不听话' + '\n'+'6.吃什么');
function shuiji() {
    var i = Math.floor(Math.random() * (2 - 1 + 1)) + 1;
    switch (parseInt(dinyi)) {
        case 1:
            if (i == 1) {
                alert('不吃');
                
            } else {
                alert('吃')
            }
            return 0;
        case 2:
            if (i == 1) {
                alert('不去')
            } else {
                alert('去')
            }
            return 0;
        case 3:
            if (i == 1) {
                alert('该锻炼啦，你看看你的双下巴')
            } else {
                alert('锻炼还是健康的锻炼')
            }
            return 0;
        case 4:
            if (i == 1) {
                alert('你忍不住买吧，要不然睡不着')
            } else {
                alert('工资不允许不买')
            }
            return 0;
        case 5:
            if (i == 1) {
                alert('仙女选择听话')
            } else {
                alert('又不是我的问题管他的')
            }
            return 0;
            case 6:
                var sum1=['桃子','西瓜','菠萝','葡萄','哈密瓜','面条','混沌','大米饭'];
                var sum=Math.floor(Math.random()*((sum1.length-1)-0+1)+0);
                alert(sum1[sum]);
                return 10;
            
        default:
            break;
    }
}
alert("会出现三次机会，小数服从多数//只有第六个选项没有三次机会");
var p=shuiji();
while (p<2) {
    shuiji();
    p++;
}

// for(var i=0;i<3;i++){
//    shuiji();
// }
    </script>
</head>

<body>
  
    <div class="bg1"></div>
    <div class="bg2"></div>
    <div class="img"></div>
    
</body>

</html>